IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_EntityMetaFieldLinkSelectForType]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[cms_sp_EntityMetaFieldLinkSelectForType]
GO

create procedure [dbo].[cms_sp_EntityMetaFieldLinkSelectForType]
(
	@EntityTypeParamater nvarchar(500)
)
as
select emfl.*,
	   emfl.EntityMetaFieldLinkId as Id,
	   emf.EntityMetaFieldId as EntityMetaField_EntityMetaFieldId,
	   emf.IsSystem as EntityMetaField_IsSystem,
	   emf.MetaFieldName as EntityMetaField_MetaFieldName,
	   emf.MetaFieldType as EntityMetaField_MetaFieldType,
	   emf.MetaFieldDescription as EntityMetaField_MetaFieldDescription
from EntityMetaFieldLinks emfl
inner join EntityMetaFields emf on emf.EntityMetaFieldId = emfl.EntityMetaFieldId
where emfl.EntityTypeParameter = @EntityTypeParamater
order by emfl.MetaFieldOrder


GO


